﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.39	合同信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_LOAN_CONTRACT: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_LOAN_CONTRACT()
		{}
		#region Model
		private long _id;
		private long _proid;
		private string _applyid;
		private string _custname;
		private string _custno;
		private Nullable<DateTime> _applydate;
		private decimal _auditamt;
		private int _auditphase;
		private Nullable<DateTime> _auditdate;
		private decimal _generalrate;
		private decimal _rate;
		private decimal _managefeerate;
		private int _paymod;
		private int _busstype;
		private Nullable<DateTime> _startdate;
		private Nullable<DateTime> _enddate;
		private string _contractno;
		private string _ticketno;
		private Nullable<DateTime> _ticketdate;
		private string _handler;
		private decimal _advamt;
		private int _status;
		private int _loanstatus;
		private string _remark;
		private string _confirmby;
		private Nullable<DateTime> _confirmdate;
		private string _createby;
		private Nullable<DateTime> _createdate;
		private string _touser;
		private int _systemid;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 立项申请记录ID
		/// </summary>
		[DataMember]
		public long PROID
		{
			get{return _proid;}
			set{
				if ( _proid!= value)
				{
					 _proid = value;
					OnPropertyChanged("PROID");
				}
			}
		}
		/// <summary>
		/// 申请编号
		/// </summary>
		[DataMember]
		public string APPLYID
		{
			get{return _applyid;}
			set{
				if ( _applyid!= value)
				{
					 _applyid = value;
					OnPropertyChanged("APPLYID");
				}
			}
		}
		/// <summary>
		/// 客户名称
		/// </summary>
		[DataMember]
		public string CUSTNAME
		{
			get{return _custname;}
			set{
				if ( _custname!= value)
				{
					 _custname = value;
					OnPropertyChanged("CUSTNAME");
				}
			}
		}
		/// <summary>
		/// 证件号码
		/// </summary>
		[DataMember]
		public string CUSTNO
		{
			get{return _custno;}
			set{
				if ( _custno!= value)
				{
					 _custno = value;
					OnPropertyChanged("CUSTNO");
				}
			}
		}
		/// <summary>
		/// 申请日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> APPLYDATE
		{
			get{return _applydate;}
			set{
				if ( _applydate!= value)
				{
					 _applydate = value;
					OnPropertyChanged("APPLYDATE");
				}
			}
		}
		/// <summary>
		/// 批核金额
		/// </summary>
		[DataMember]
		public decimal AUDITAMT
		{
			get{return _auditamt;}
			set{
				if ( _auditamt!= value)
				{
					 _auditamt = value;
					OnPropertyChanged("AUDITAMT");
				}
			}
		}
		/// <summary>
		/// 批核期限
		/// </summary>
		[DataMember]
		public int AUDITPHASE
		{
			get{return _auditphase;}
			set{
				if ( _auditphase!= value)
				{
					 _auditphase = value;
					OnPropertyChanged("AUDITPHASE");
				}
			}
		}
		/// <summary>
		/// 批核日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> AUDITDATE
		{
			get{return _auditdate;}
			set{
				if ( _auditdate!= value)
				{
					 _auditdate = value;
					OnPropertyChanged("AUDITDATE");
				}
			}
		}
		/// <summary>
		/// 综合费率
		/// </summary>
		[DataMember]
		public decimal GENERALRATE
		{
			get{return _generalrate;}
			set{
				if ( _generalrate!= value)
				{
					 _generalrate = value;
					OnPropertyChanged("GENERALRATE");
				}
			}
		}
		/// <summary>
		/// 利率
		/// </summary>
		[DataMember]
		public decimal RATE
		{
			get{return _rate;}
			set{
				if ( _rate!= value)
				{
					 _rate = value;
					OnPropertyChanged("RATE");
				}
			}
		}
		/// <summary>
		/// 管理费率
		/// </summary>
		[DataMember]
		public decimal MANAGEFEERATE
		{
			get{return _managefeerate;}
			set{
				if ( _managefeerate!= value)
				{
					 _managefeerate = value;
					OnPropertyChanged("MANAGEFEERATE");
				}
			}
		}
		/// <summary>
		/// 还款方式
		/// </summary>
		[DataMember]
		public int PAYMOD
		{
			get{return _paymod;}
			set{
				if ( _paymod!= value)
				{
					 _paymod = value;
					OnPropertyChanged("PAYMOD");
				}
			}
		}
		/// <summary>
		/// 业务种类单选项，包括：1典当、2期间借款、3赎楼、4租赁，必填项
		/// </summary>
		[DataMember]
		public int BUSSTYPE
		{
			get{return _busstype;}
			set{
				if ( _busstype!= value)
				{
					 _busstype = value;
					OnPropertyChanged("BUSSTYPE");
				}
			}
		}
		/// <summary>
		/// 起息日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> STARTDATE
		{
			get{return _startdate;}
			set{
				if ( _startdate!= value)
				{
					 _startdate = value;
					OnPropertyChanged("STARTDATE");
				}
			}
		}
		/// <summary>
		/// 止息日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> ENDDATE
		{
			get{return _enddate;}
			set{
				if ( _enddate!= value)
				{
					 _enddate = value;
					OnPropertyChanged("ENDDATE");
				}
			}
		}
		/// <summary>
		/// 主合同编号
		/// </summary>
		[DataMember]
		public string CONTRACTNO
		{
			get{return _contractno;}
			set{
				if ( _contractno!= value)
				{
					 _contractno = value;
					OnPropertyChanged("CONTRACTNO");
				}
			}
		}
		/// <summary>
		/// 当票编号
		/// </summary>
		[DataMember]
		public string TICKETNO
		{
			get{return _ticketno;}
			set{
				if ( _ticketno!= value)
				{
					 _ticketno = value;
					OnPropertyChanged("TICKETNO");
				}
			}
		}
		/// <summary>
		/// 开票日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> TICKETDATE
		{
			get{return _ticketdate;}
			set{
				if ( _ticketdate!= value)
				{
					 _ticketdate = value;
					OnPropertyChanged("TICKETDATE");
				}
			}
		}
		/// <summary>
		/// 经办人
		/// </summary>
		[DataMember]
		public string HANDLER
		{
			get{return _handler;}
			set{
				if ( _handler!= value)
				{
					 _handler = value;
					OnPropertyChanged("HANDLER");
				}
			}
		}
		/// <summary>
		/// 预收费用
		/// </summary>
		[DataMember]
		public decimal ADVAMT
		{
			get{return _advamt;}
			set{
				if ( _advamt!= value)
				{
					 _advamt = value;
					OnPropertyChanged("ADVAMT");
				}
			}
		}
		/// <summary>
		/// 合同状态-1未生成
        ///0保存（未提交）
        ///1审批中
        ///2审批通过
        ///3已打印
        ///4已签订
        ///5已开当票
        ///6未开当票
		/// </summary>
		[DataMember]
		public int STATUS
		{
			get{return _status;}
			set{
				if ( _status!= value)
				{
					 _status = value;
					OnPropertyChanged("STATUS");
				}
			}
		}
		/// <summary>
		/// 放款状态0未放款1部分放款2已放款
		/// </summary>
		[DataMember]
		public int LOANSTATUS
		{
			get{return _loanstatus;}
			set{
				if ( _loanstatus!= value)
				{
					 _loanstatus = value;
					OnPropertyChanged("LOANSTATUS");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 确认人
		/// </summary>
		[DataMember]
		public string CONFIRMBY
		{
			get{return _confirmby;}
			set{
				if ( _confirmby!= value)
				{
					 _confirmby = value;
					OnPropertyChanged("CONFIRMBY");
				}
			}
		}
		/// <summary>
		/// 确认日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CONFIRMDATE
		{
			get{return _confirmdate;}
			set{
				if ( _confirmdate!= value)
				{
					 _confirmdate = value;
					OnPropertyChanged("CONFIRMDATE");
				}
			}
		}
		/// <summary>
		/// 建档人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 建档日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 提交到
		/// </summary>
		[DataMember]
		public string TOUSER
		{
			get{return _touser;}
			set{
				if ( _touser!= value)
				{
					 _touser = value;
					OnPropertyChanged("TOUSER");
				}
			}
		}
		/// <summary>
		/// 所属子系统
		/// </summary>
		[DataMember]
		public int SYSTEMID
		{
			get{return _systemid;}
			set{
				if ( _systemid!= value)
				{
					 _systemid = value;
					OnPropertyChanged("SYSTEMID");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

